package com.trippin.Utils;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Date;

import com.trippin.DB.entities.ScheduledAttractionEntity;

public class ScheduledAttractionEntityComparator implements Comparator<ScheduledAttractionEntity>, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public int compare(ScheduledAttractionEntity sae1,
			ScheduledAttractionEntity sae2) {
		
		Date start1 = sae1.getStartTime();
		Date start2 = sae2.getStartTime();
		
		if(start1.before(start2)) {
			return 1;
		}
		else if(start1.after(start2)){
			return -1;
		}
		else {
			Date end1 = sae1.getEndTime();
			Date end2 = sae2.getEndTime();
			if(end1.before(end2)) {
				return 1;
			}
			else {
				return -1;
			}			
		}
	}

}
